<%-- 
    Document   : warn
    Created on : 2013-5-7, 11:42:30
    Author     : piaohao
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
    <head>
        <base href="<%= basePath%>"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@include file="../main/common.jsp" %>
        <title>车辆档案</title>
        <script type="text/javascript">
            Ext.onReady(function() {
                var warnStore = Ext.create('Ext.data.Store', {
                    fields: ["id", "content", "create_time"],
                    pageSize: 15,
                    proxy: {
                        type: 'ajax',
                        url: 'warn/resultList',
                        reader: {
                            type: 'json',
                            root: 'data'
                        }
                    },
                    autoLoad: true
                });
                var warnGrid = Ext.create("Ext.grid.Panel", {
                    title: "预警列表",
                    columnLines: true,
                    frame: true,
                    selType: 'checkboxmodel', // 设置选择模式 
                    multiSelect: true, // 允许多选
                    forceFit: true,
                    columns: [
                        {header: '主键', dataIndex: 'id', hidden: true},
                        {header: '内容', dataIndex: 'content', width: 200},
                        {header: '扫描日期', dataIndex: 'create_time', width: 100}
                    ],
                    store: warnStore,
                    tbar: [
                        {xtype: "button", text: "查看", iconCls: "search",
                            handler: function() {
                                var sel = warnGrid.getSelectionModel().getSelection();
                                if (sel.length !== 1) {
                                    Ext.Msg.alert("提示", "请选择1条且仅有1条记录！");
                                    return;
                                }
                                var record = sel[0].data;
                                var detailWindow = Ext.create("Ext.window.Window", {
                                    title: "预警信息",
                                    maximized: true,
                                    maximizable: true,
                                    closeAction: "hide",
                                    layout: "fit",
                                    html: "<iframe id='detailFrame' src='warn/showResultDetail/" + record.id + "' width='100%' height='100%'></iframe>",
                                    buttons: [
                                        {text: "打印", iconCls: "print",
                                            handler: function() {
                                                Ext.get("detailFrame").dom.contentWindow.print();
                                            }},
                                        {text: "关闭", iconCls: "close",
                                            handler: function() {
                                                detailWindow.close();
                                            }}
                                    ]
                                });
                                detailWindow.show();
                            }}
                    ],
                    bbar: Ext.create('Ext.PagingToolbar', {
                        store: warnStore,
                        displayInfo: true
                    })
                });
                var viewport = Ext.create("Ext.Viewport", {
                    layout: {type: "border"},
                    items: [
                        {region: "center", layout: "fit", items: [warnGrid]}
                    ]
                });
            });
        </script>
    </head>
    <body>
    </body>
</html>
